package com.example.hospital_208.service.impl;

import com.example.hospital_208.dao.DepartmentDao;
import com.example.hospital_208.po.Department;
import com.example.hospital_208.service.DepartmentService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {

    private final DepartmentDao departmentDao;

    public DepartmentServiceImpl(DepartmentDao departmentDao) {
        this.departmentDao = departmentDao;
    }

    @Override
    public List<String> listMainDepartmentNames() {
        return departmentDao.findMainDepartmentNames();
    }
    @Override
    public Integer getDepartmentIdByName(String departmentName) {
        return departmentDao.findDepartmentIdByName(departmentName);
    }

    @Override
    public List<String> listSubDepartmentNames(Integer parentId) {
        return departmentDao.findSubDepartmentNames(parentId);
    }

    // 原有方法实现保持不变...
    @Override
    public List<Department> listDepartments() {
        return departmentDao.findAllDepartments();
    }

    @Override
    public Department getDepartmentById(Integer department_id) {
        return departmentDao.findDepartmentById(department_id);
    }

    @Override
    public int addDepartment(Department department) {
        return departmentDao.insertDepartment(department);
    }

    @Override
    public int editDepartment(Department department) {
        return departmentDao.updateDepartment(department);
    }

    @Override
    public int removeDepartment(Integer department_id) {
        return departmentDao.deleteDepartmentById(department_id);
    }
}